---------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\Users\user\Documents\work/DNB_survey_consumption/ConGrowth/Replication/Programs/Descriptive/Descriptive_sta
> ts_graphs.log
  log type:  text
 opened on:  11 Dec 2018, 12:01:22

. 
. global stdate $S_DATE 

. global sttime $S_TIME

. noisily display "Begin program at ${sttime} on ${stdate}"   /* time stamp */
Begin program at 12:01:22 on 11 Dec 2018

. 
. *Setting the scheme
. global schm s1mono

. 
. *Read the person-level data in long form
. use "${projf}/Data/Data_cons_uncertainty.dta", clear

. 
. *Using only the observations that appear in the regression
. qui keep if hpconch_nyr!=. & hm`dist'_sqcgr!=. & regio!=.

. 
. *Generating integer weights
. qui gen double intwgtp=round(wgth*1000)

. 
. *Fig. 1a Histogram of the minimum of future consumption level
. hist hmin_sp if hmin_sp<8000 [fw=intwgtp], bin(30) scheme(${schm}) ytitle(,margin(medium)) ///
>    xtitle("Minimum expected consumption level",margin(medium)) ytitle("Sample proportion") /*freq*/frac /*ylabel(.0001 .0
> 003 .0005)*/ ///
>    xlabel(0(2000)8000, format(%5.0fc)) saving("${projf}/Results/Graphs/temp1.gph", replace)
(bin=30, start=30, width=182.33333)
(note: file C:\Users\user\Documents\work/DNB_survey_consumption/ConGrowth/Replication/Results/Graphs/temp1.gph not found)
(file C:\Users\user\Documents\work/DNB_survey_consumption/ConGrowth/Replication/Results/Graphs/temp1.gph saved)

. *graph export "${projf}/Results/Graphs/Fig1_min_`dist'.wmf", replace     
. 
. *Fig. 1b Histogram of the maximum of future consumption level
. hist hmax_sp if hmax_sp<8000 [fw=intwgtp], bin(30) scheme(${schm}) ytitle(,margin(medium)) ///
>    xtitle("Maximum expected consumption level",margin(medium)) ytitle("Sample proportion") /*freq*/frac /*ylabel(.0001 .0
> 003 .0005)*/ ///
>    xlabel(0(2000)8000, format(%5.0fc)) saving("${projf}/Results/Graphs/temp2.gph", replace)
(bin=30, start=60, width=214.66667)
(note: file C:\Users\user\Documents\work/DNB_survey_consumption/ConGrowth/Replication/Results/Graphs/temp2.gph not found)
(file C:\Users\user\Documents\work/DNB_survey_consumption/ConGrowth/Replication/Results/Graphs/temp2.gph saved)

. *graph export "${projf}/Results/Graphs/Fig2_max_`dist'.wmf", replace     
. 
. *Fig. 1c Histogram of the probability of being above the average of the min and max values
. *of the future consumption level
. hist hpi_sp [fw=intwgtp], scheme(${schm}) ytitle(,margin(medium)) ///
>    xtitle("Probability",margin(medium)) /*ylabel()*/ ytitle("Sample proportion") /*freq*/frac ///
>    xlabel(0(.1)1, format(%3.1fc)) saving("${projf}/Results/Graphs/temp3.gph", replace)
(bin=64, start=0, width=.015625)
(note: file C:\Users\user\Documents\work/DNB_survey_consumption/ConGrowth/Replication/Results/Graphs/temp3.gph not found)
(file C:\Users\user\Documents\work/DNB_survey_consumption/ConGrowth/Replication/Results/Graphs/temp3.gph saved)

. *graph export "${projf}/Results/Graphs/Fig3_prob_`dist'.wmf", replace     
. 
. *Fig. 1d Histogram of the expected square of consumption growth
. hist w005_hm`dist'_sqcgr if w005_hm`dist'_sqcgr<.05 [fw=intwgtp], bin(30) scheme(${schm}) ytitle("Sample proportion") /*f
> req*/frac ///
>    xtitle("Expected square of consumption growth",margin(medium)) /*ylabel()*/ ///
>    xlabel(0(.01).05, format(%4.2fc)) saving("${projf}/Results/Graphs/temp4.gph", replace)
(bin=30, start=0, width=.00165327)
(note: file C:\Users\user\Documents\work/DNB_survey_consumption/ConGrowth/Replication/Results/Graphs/temp4.gph not found)
(file C:\Users\user\Documents\work/DNB_survey_consumption/ConGrowth/Replication/Results/Graphs/temp4.gph saved)

. 
. 
. gr combine "${projf}/Results/Graphs/temp1.gph" ///
>            "${projf}/Results/Graphs/temp2.gph" ///
>            "${projf}/Results/Graphs/temp3.gph" ///
>            "${projf}/Results/Graphs/temp4.gph", scheme(${schm}) saving("${projf}/Results/Graphs/Fig1.gph", replace)
(note: file C:\Users\user\Documents\work/DNB_survey_consumption/ConGrowth/Replication/Results/Graphs/Fig1.gph not found)
(file C:\Users\user\Documents\work/DNB_survey_consumption/ConGrowth/Replication/Results/Graphs/Fig1.gph saved)

. graph export "${projf}/Results/Graphs/Fig1_`dist'.wmf", replace     
(file C:\Users\user\Documents\work/DNB_survey_consumption/ConGrowth/Replication/Results/Graphs/Fig1_sptri.wmf written in Wi
> ndows Metafile format)

. 
. erase "${projf}/Results/Graphs/temp1.gph"

. erase "${projf}/Results/Graphs/temp2.gph"

. erase "${projf}/Results/Graphs/temp3.gph"

. erase "${projf}/Results/Graphs/temp4.gph"

. erase "${projf}/Results/Graphs/Fig1.gph"

. 
. *Fig. 2. Expected square of consumption growth by age categories 
. 
. *Age categories
. gen byte agecat = recode(age,30,40,50,60,70,80)

. 
. preserve

. 
. collapse (p50) w005_hsd`dist'_consgr w005_hm`dist'_sqcgr w005_hpconch_nyr [aw=wgth],by(agecat)

. 
. qui twoway (scatter w005_hm`dist'_sqcgr agecat, mlabsize(vsmall)) (lfit w005_hm`dist'_sqcgr agecat), legend(off) scheme($
> {schm}) ///
>    ytitle("Median expected square of" "consumption growth", margin(medium)) xtitle("Age",margin(medium)) ylabel(0.0(.002)
> .008) ///
>    xlabel(30(10)80, format(%3.0fc)) title(" ") note(" ") saving("${projf}/Results/Graphs/temp1.gph", replace)

. graph export "${projf}/Results/Graphs/Fig2_`dist'.wmf", replace     
(file C:\Users\user\Documents\work/DNB_survey_consumption/ConGrowth/Replication/Results/Graphs/Fig2_sptri.wmf written in Wi
> ndows Metafile format)

. erase "${projf}/Results/Graphs/temp1.gph"

. 
. restore

. 
. 
. *Fig. 3 Expected consumption growth by values of expected square of consumption growth
. 
. *Categories of expected square of of consumption growth based in deciles
. _pctile w005_hm`dist'_sqcgr [aw=wgth],nq(10)

. gen double m_sqcgr_cat = recode(w005_hm`dist'_sqcgr,r(r1),r(r2),r(r3),r(r4),r(r5),r(r6),r(r7),r(r8),r(r9))

. 
. preserve

. 
. collapse (mean) w005_hpconch_nyr [aw=wgth],by(m_sqcgr_cat)

. 
. qui twoway (scatter w005_hpconch_nyr m_sqcgr_cat, mlabsize(vsmall)) (lfit w005_hpconch_nyr m_sqcgr_cat), scheme(${schm}) 
> legend(off) ///
>    ytitle("Average of expected consumption growth", margin(medium)) ///
>    xtitle("Levels of expected square" "of consumption growth",margin(medium)) ylabel(-.02(.02).06) ///
>    xlabel(0(.005).025, format(%5.3fc)) saving("${projf}/Results/Graphs/temp1.gph", replace)

. graph export "${projf}/Results/Graphs/Fig3_`dist'.wmf", replace     
(note: file C:\Users\user\Documents\work/DNB_survey_consumption/ConGrowth/Replication/Results/Graphs/Fig3_sptri.wmf not fou
> nd)
(file C:\Users\user\Documents\work/DNB_survey_consumption/ConGrowth/Replication/Results/Graphs/Fig3_sptri.wmf written in Wi
> ndows Metafile format)

. erase "${projf}/Results/Graphs/temp1.gph"

. 
. restore

. 
. *Fig. A2 Expected consumption growth by values of the expected square of income growth
. 
. *Categories of expected square of of income growth based in deciles
. _pctile w005_hm`dist'_sqincgr [aw=wgth],nq(10)

. gen double m_sqincgr_cat = recode(w005_hm`dist'_sqincgr,r(r1),r(r2),r(r3),r(r4),r(r5),r(r6),r(r7),r(r8),r(r9))
(376 missing values generated)

. 
. preserve

. 
. collapse (mean) w005_hpconch_nyr [aw=wgth],by(m_sqincgr_cat)

. 
. qui twoway (scatter w005_hpconch_nyr m_sqincgr_cat, mlabsize(vsmall)) (lfit w005_hpconch_nyr m_sqincgr_cat), scheme(${sch
> m}) legend(off) ///
>    ytitle("Average of expected consumption growth", margin(medium)) ///
>    xtitle("Levels of expected square" "of income growth",margin(medium)) ylabel(-.02(.02).06) ///
>    xlabel(0(0.03).3, format(%5.2fc)) saving("${projf}/Results/Graphs/temp1.gph", replace)

. graph export "${projf}/Results/Graphs/FigA2_`dist'.wmf", replace     
(file C:\Users\user\Documents\work/DNB_survey_consumption/ConGrowth/Replication/Results/Graphs/FigA2_sptri.wmf written in W
> indows Metafile format)

. erase "${projf}/Results/Graphs/temp1.gph"

. 
. restore

. 
. *Table 1 Descriptive statistics
. tabstat hmin_sp hmax_sp hpi_sp w005_hpconch_nyr w005_hsd`dist'_consgr w005_hm`dist'_sqcgr w005_hsd`dist'_incgr age ///
>     fem hhsize couple [aw=wgth],statistics(mean p50 sd) columns(statistics) save

    variable |      mean       p50        sd
-------------+------------------------------
     hmin_sp |  1484.229      1400  912.7331
     hmax_sp |  1882.197      1750  1147.834
      hpi_sp |  .4757047        .5  .2280739
w005_hpcon~r |  .0180042         0  .0957215
w005_hsdsp.. |  .0486739  .0400153  .0406972
w00~ri_sqcgr |  .0157122   .002992  .0711084
w005_hsdsp.. |   .027853  .0157331  .0430144
         age |  51.96292        52   16.0748
         fem |  .4062028         0  .4912009
      hhsize |  2.196242         2  1.245861
      couple |  .6037916         1  .4891859
--------------------------------------------

. tabstatmat A

A[3,11]
                   hmin_sp               hmax_sp                hpi_sp      w005_hpconch_nyr  w005_hsdsptri_consgr
mean             1484.2288             1882.1972             .47570468             .01800419             .04867392
 p50                  1400                  1750                    .5                     0             .04001528
  sd             912.73311             1147.8339             .22807386             .09572147             .04069716

        w005_hmsptri_sqcgr   w005_hsdsptri_incgr                   age                   fem                hhsize
mean             .01571217             .02785299             51.962918             .40620283             2.1962417
 p50             .00299197             .01573313                    52                     0                     2
  sd             .07110842             .04301439               16.0748             .49120085             1.2458615

                    couple
mean             .60379159
 p50                     1
  sd             .48918592

. mat A = A'

. local rn = colsof(A)

. mat B = J(1,`rn',.)

. qui count

. mat B[1,1]=r(N)

. mat A = (A\B)

. 
. mat list A

A[12,3]
                   mean        p50         sd
     hmin_sp  1484.2288       1400  912.73311
     hmax_sp  1882.1972       1750  1147.8339
      hpi_sp  .47570468         .5  .22807386
w005_hpcon~r  .01800419          0  .09572147
w005_hsdsp..  .04867392  .04001528  .04069716
w00~ri_sqcgr  .01571217  .00299197  .07110842
w005_hsdsp..  .02785299  .01573313  .04301439
         age  51.962918         52    16.0748
         fem  .40620283          0  .49120085
      hhsize  2.1962417          2  1.2458615
      couple  .60379159          1  .48918592
          r1       3167          .          .

. 
. mat2txt, mat(A) saving("${projf}/Results/Descriptive/Descriptive_Statistics_`dist'.txt") replace format(%15.6f) ///      
>   title("Descriptive Statistics, $S_DATE, $S_TIME")      

. 
. 
. *Time stamp
. noisily display "Program started at: ${sttime} of ${stdate}"      /* beginning time stamp */
Program started at: 12:01:22 of 11 Dec 2018

. noisily display "Program finished at: $S_TIME of $S_DATE"       /*ending time stamp*/       
Program finished at: 12:01:34 of 11 Dec 2018

. 
. cap log close
